<!DOCTYPE html>
<html>
<head>
	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="__PUBLIC__/easyui/locale/easyui-lang-zh_CN.js"></script>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/gray/easyui.css">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/easyui/themes/icon.css">
	<script type="text/javascript" src="__PUBLIC__/js/add-tab.js"></script>
	<script type="text/javascript">
		function formatTime(val,row) {     
   	 		return new Date(parseInt(val) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
		}   
	</script>
</head>
<body>
	<div id="tb" style="padding:5px;height:auto">
		<div style="margin-bottom:5px">
			<a href="javascript:void(0);" src="__URL__/editDraft" class="easyui-linkbutton cs-navi-tab-edit" id="edit_process" iconCls="icon-search">编辑提交</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" id="del_process" iconCls="icon-employe-del">删除流程</a>
		</div>
	</div>
	<table id="tt" title="草稿箱" class="easyui-datagrid" style="width:auto;height:auto;" iconCls="icon-employe" data-options="rownumbers:true,singleSelect:true,url:'__URL__/DraftApprovalData',toolbar:'#tb',iconCls:'icon-draft'" pagination="true" fitColumns="true" fit='true' pageSize="20" pageList="[20,40,80]">
		<thead>
			<tr>
				<th field="process_num" width="80">流程号</th>
				<th field="process_title" width="80">流程名称</th>
				<th field="process_now_id" width="80">下一步执行人员</th>
				<th field="process_time" width="80" formatter="formatTime">保存时间</th>
			</tr>
		</thead>
	</table>
<script type="text/javascript">
	$(function(){
		var i=1;
		var j=1;
		$('#tt').datagrid({
			onDblClickRow: function(rowIndex,rowData){
					var $this = $('.cs-navi-tab-edit');
					var href = $this.attr('src') + '?process_id=' + rowData.process_id + '&process_type=' + rowData.process_type;
					var title = $this.text()+i;
					i++;
					addTab(title, href);
			}
		});
		$('#edit_process').click(function(){
			var row = $('#tt').datagrid('getSelected');
			if(row){
				var $this = $('.cs-navi-tab-edit');
				var href = $this.attr('src')+'?process_id='+row.process_id+'&process_type='+row.process_type;
				var title = $this.text()+j;
				j++;
				addTab(title, href);
			}
			else {
            	$.messager.alert('提示', '请选择一条流程', 'info');
            }
		})
		$('#del_process').click(function(){
			var row = $('#tt').datagrid('getSelected');
			
            if(row) {
                $.messager.confirm('提示信息', '是否删除该条流程?', function(r){
                    if(r){
                        $.ajax({
                        	type:'post',
                            url: '__URL__/delDraft',
                            data: {process_id:row.process_id,process_type:row.process_type},
                            success: function (data) {
                            	if(data=='ok'){
                            		$.messager.alert('提示', '删除成功', 'info');
                            		$('#tt').datagrid('reload');
                            	} 
                                if(data=='no'){
                                	$.messager.alert('提示', '删除失败', 'info');
                                }
                            }
                        });
                    }
                });
            }
            else {
            	$.messager.alert('提示', '请选择员工', 'info');
            }
		})
	});	
</script>
</body>
</html>